package cn.bugstack.springframework.beans.factory.support;

import cn.bugstack.springframework.beans.BeanException;
import cn.bugstack.springframework.beans.factory.config.BeanDefinition;

public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFactory {


    @Override
    protected Object createBean(String beanName, BeanDefinition beanDefinition) throws BeanException {
        Object bean = null;
        try {
            bean  = beanDefinition.getBeanClass().newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            throw new BeanException("failed",e);
        }
        //放到单例中
        addSingleton(beanName,bean);
        return bean;
    }
}
